/**
 * Created by hxpeng on 2017/4/28.
 */
(function () {
    'use strict';

    angular.module('App.pages.bind')
        .controller('BindConfirmCtrl', BindConfirmCtrl);

    function BindConfirmCtrl($scope,AppUtils,$location,StoreUtils,LoginAccountAuth,MemberModel) {
        var vm = this;

        LoginAccountAuth.getAccount()
            .then(function (data) {
                vm.memberVo = StoreUtils.getObj("bindMemberVo");
                vm.memberVo.openId = data.openId;

                vm.student = {};
                vm.class = {};
                vm.class = StoreUtils.getObj("class");
            });

        $scope.postMemberInfo = function(){
            MemberModel.bindWeChatInfo(vm.memberVo).$promise.then(function(response){
                if(response.stat == 'err'){
                    AppUtils.showAlert(response.msg);
                }else{
                    var loginAccountVo = response.loginAccountVo;
                    LoginAccountAuth.setAccount(loginAccountVo);
                    AppUtils.showAlert("绑定成功！");
                    $location.path("/class/teacherIndex");

                }
            })
        }

    }

})();
